# 1.导包（快捷键：alt + enter）
import time
from api.login import user_test
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service

index = [
    {'userA': '张三', 'passwordA': 11, 'telA': '12345678900', 'emailA': '12345678900@qq.com'},
    {'userA': '李四', 'passwordA': 22, 'telA': '12345678901', 'emailA': '12345678901@qq.com'},
    {'userA': '王五', 'passwordA': 33, 'telA': '12345678902', 'emailA': '12345678902@qq.com'}
]

keys = index[0].keys()
keys_list = list(keys)


# 2.打开浏览器（创建浏览器驱动对象）
# path = r"E:\Python\chromedriver.exe" # 定义驱动路径
# ser = Service(executable_path=path) # 实例化Chrome浏览器服务驱动
driver = webdriver.Chrome(executable_path=r"E:\Python\chromedriver.exe") # 打开Chrome浏览器
# 3.输入网址
driver.get("http://121.43.169.97:8848/pageA.html")
# 4.页面操作

for form_data in index:
    for key_name in keys_list:
        element = WebDriverWait(driver, 10, 1).until(user_test(key_name))
        element.send_keys(form_data[key_name])



# 5.等待2秒
time.sleep(2)
# 6.退出浏览器
driver.quit()